package Example11_3;
import java.sql.*;

public class Example11_3 {
    public static void main(String args[]) {
        Connection con;
        Statement sql;
        ResultSet rs;
        float min=70,max=0;
        con = GetDBConnection.connectDB("world","root","");
        if(con == null ) return;
        String c1=" Region Like 'Middle East'";//条件1
        String c2="";
        String c3="";
        String sqlStr =
                "select * from country";
        try {
            sql=con.createStatement();
            rs = sql.executeQuery(sqlStr);
            while(rs.next()) {
                float a = rs.getFloat(8);
                if(a == 0.0){
                    continue;
                }
                if (a>max){
                    max = a;
                }
                if (a<min){
                    min = a;
                }
            }
        }
        catch(SQLException e) {
            System.out.println(e);
        }
        try {
            sql=con.createStatement();
            rs = sql.executeQuery(sqlStr);
            while(rs.next()) {
                if(max == rs.getFloat(8)){
                    System.out.println("The Longest is:"+rs.getString(2));
                }
                if(min == rs.getFloat(8)){
                    System.out.println("The shortest is:"+rs.getString(2));
                }
            }
            con.close();
        }
        catch(SQLException e) {
            System.out.println(e);
        }
        System.out.println(min+"     "+max);
    }
}

